import java.util.Random;

public class 随机生成树 {
    public static void main(String[] args) {
        //生成 5 个随机数存入数组
        Random r = new Random();
        int[] arr = new int[5];
        //1.
        for (int i = 0; i < arr.length; i++) {
            arr[i] = r.nextInt(100) + 1;
        }
        //数组求和
        int sum = 0;


        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        //2.
        System.out.println("数组的和为：" + sum);
        //获取数组中角标和对应的元素都为偶数的元素,判断后一定要打印元素哦
        System.out.println("数组中角标和对应的元素都为偶数的元素有：");
        //3
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0 && i % 2 == 0) {
                System.out.println(arr[i]);
            }
        }
    }
}
